global path = "~/Box Sync/JHMedBox/"
clear all
set more off 
set matsize 11000

cd  "$path/daca_oregon_notshared/data/"
use allkids2_recoded.dta, clear

* limit to first claim to have one obs per child
keep if tag1

* cluster indicator
egen clid = group(mother_SAK_RECIP)

///// Fig 1: Results from Regression Discontinuity Design 

// top panel: effect of DACA elegibility
reg y_300308309 Z##c.rvd   if mother_CWCX==1 & bwd<=150, cl(mother_SAK_RECIP)

// lower left panel: placebo test
reg y_300308309_p Z##c.rvd   if mother_CWCX==1 & bwd<=150, cl(mother_SAK_RECIP)

// compute binned means for 15 day intervals
preserve
keep if mother_CWCX==1
gen     ba15 = autocode(rvd,(3990+2790)/15,-3990,2790)
replace ba15 = ba15 - (15/2)

foreach x of varlist y_300308309 y_308309 y_300 y_300308309_p  {
egen ba15mean`x' = mean(`x') , by(ba15)
}

keep ba*
saveold weekmeans.dta, replace version(11)
restore

// lower right panel: more placebo tests
capture matrix drop res
foreach y of varlist y_visitop_p y_visiter_p y_visit_p yob mob female ///
                     xxethnhis xxethhis xxethdk racecat* age2015  {
rdbwselect `y' rvd         if mother_CWCX==1 , vce(cluster clid)  
reg `y' Z##c.rvd   if mother_CWCX==1 & bwd<=`e(h_mserd)', cl(mother_SAK_RECIP)
matrix  pweight = (2 * ttail(e(df_r), abs(_b[1.Z]/_se[1.Z])))
matrix rownames pweight = "`y'"
matlist pweight
mat res = nullmat(res) \ pweight
}
matlist res
cd  "$path/daca_oregon_notshared/results/"
mat2txt , matrix(res) saving(res_fig1c.txt) replace




//// Fig. 2: Effect of Mothers’ DACA Eligibility on their Children’s Mental Health (left panel; post daca period)
global yvars = "y_300308309 y_308309 y_300"
capture matrix drop res
cap local drop counter
local counter = 1
foreach y of global yvars {
* select bw
rdbwselect `y' rvd  if mother_CWCX==1 , vce(cluster clid)
global bw`counter' = `e(h_mserd)'
* fit model
reg `y' Z##c.rvd   if mother_CWCX==1 & bwd<=`e(h_mserd)', cl(mother_SAK_RECIP)

* store results for figure
matrix coefse = _b[1.Z] , _se[1.Z]
matrix rownames coefse = "`y'"
matlist coefse
mat res = nullmat(res) \ coefse

* store results for table
global pe1`counter' = _b[1.Z]
global se1`counter' = _se[1.Z]
global ppe`counter' =  (_b[1.Z] / _b[_cons])*100
global pe2`counter' = _b[_cons]
global se2`counter' = _se[_cons]
global obs`counter' = `e(N)'
local counter = `counter' + 1
di "`counter'"
}

//// Table S.5: Regression Discontinuity Design Estimates: Effect of Mothers’ DACA Eligibility on Children’s Mental Health
cd "/Users/jhainmueller/Dropbox (IPL)/daca_oregon/draft/Science/tables"
cap file close myfile
file open myfile using tabS5.tex, write replace
global WRITE file write myfile
$WRITE "\begin{table}[!hbt]" _n
$WRITE "  \centering" _n
$WRITE "  \small" _n
$WRITE "  \caption{\bf Regression Discontinuity Design Estimates: Effect of Mothers' DACA Eligibility on Children's Mental Health}\label{tab:S5}" _n
$WRITE "    \begin{tabular}{lccc}" _n
$WRITE "    \hline \hline" _n
$WRITE "          &    Adjustment or  & Adjustment  & Anxiety    \\" _n
$WRITE " Outcome         &    Anxiety Disorder      & Disorder & Disorder    \\" _n
$WRITE "\hline" _n
$WRITE "  Model        &    (1)   & (2)  & (3)    \\" _n
$WRITE "\hline" _n
$WRITE  "Effect of Mothers'   & "  %9.2f ( $pe11 ) " & " %9.2f ( $pe12 ) " & "  %9.2f ( $pe13 )  " \\" _n
$WRITE  "DACA Eligibility  & ("  %9.2f ( $se11 ) ") & (" %9.2f ( $se12 ) ") & ("  %9.2f ( $se13 )  ") \\" _n
$WRITE "\hline" _n
$WRITE  "Number of children & "  %9.0f ( $obs1 ) " & " %9.0f ( $obs2 ) " & " %9.0f ($obs3) " \\ " _n
$WRITE  "Optimal bandwidth ($\pm$ days) & "  %9.0f ( $bw1 ) " & " %9.0f ( $bw2 ) " & "  %9.0f ( $bw3 )  " \\" _n
$WRITE "\hline" _n
$WRITE  "Percent change ($100\,(\frac{\hat{\tau}}{\hat{\alpha}}$)) & "  %9.2f ( $ppe1 ) " & " %9.2f ( $ppe2 ) " & "  %9.2f ( $ppe3 )  " \\" _n
$WRITE "    \hline \hline" _n
$WRITE "\multicolumn{4}{p{0.8\textwidth}}{\scriptsize Regression coefficients from local linear regression shown with robust standard errors (clustered by mother) in parentheses. The estimation samples are determined by an adaptive mean-squared error optimal bandwidth selection. All models include the distance variable and its interaction with the DACA eligibility indicator. The outcome variables are coded as 0 or 100 such that the effect estimates of the regression coefficients are measured in percentage points. The percent change in the last row is computed as $100\,(\frac{\hat{\tau}}{\hat{\alpha}}$) and measures at the DACA birthdate cutoff the effect of mothers' DACA elegibility ($\hat{\tau}$) divided by the estimated average diagnoses rate for children of ineligible mothers ($\hat{\alpha}$). See text for details.}" _n
$WRITE "    \end{tabular} " _n
$WRITE " \end{table} " _n
file close myfile


//// Fig. 2: Effect of Mothers’ DACA Eligibility on their Children’s Mental Health (right panel; pre daca period)

global yvars = "y_300308309_p y_308309_p y_300_p"
cap local drop counter
local counter = 1
foreach y of global yvars {
rdbwselect `y' rvd  if mother_CWCX==1 , vce(cluster clid)
global bw`counter' = `e(h_mserd)'
reg `y' Z##c.rvd   if mother_CWCX==1 & bwd<=`e(h_mserd)', cl(mother_SAK_RECIP)

* store results for figure
matrix coefse = _b[1.Z] , _se[1.Z]
matrix rownames coefse = "`y'"
matlist coefse
mat res = nullmat(res) \ coefse

* store results for table
global pe1`counter' = _b[1.Z]
global se1`counter' = _se[1.Z]
global ppe`counter' =  (_b[1.Z] / _b[_cons])*100
global pe2`counter' = _b[_cons]
global se2`counter' = _se[_cons]
global obs`counter' = `e(N)'
local counter = `counter' + 1
di "`counter'"
}

//// Table S.6: Regression Discontinuity Design Estimates: Placebo Effect of Mothers’ DACA Eligibility on Children’s Mental Health in Pre-DACA Period

cd "/Users/jhainmueller/Dropbox (IPL)/daca_oregon/draft/Science/tables"
cap file close myfile
file open myfile using tabS6.tex, write replace
global WRITE file write myfile
$WRITE "\begin{table}[!hbt]" _n
$WRITE "  \centering" _n
$WRITE "  \small" _n
$WRITE "  \caption{\bf Regression Discontinuity Design Estimates: Effect of Mothers' DACA Eligibility on Children's Mental Health in Pre-DACA Period}\label{tab:S6}" _n
$WRITE "    \begin{tabular}{lccc}" _n
$WRITE "    \hline \hline" _n
$WRITE "          &    Adjustment or  & Adjustment  & Anxiety    \\" _n
$WRITE " Outcome         &    Anxiety Disorder      & Disorder & Disorder    \\" _n
$WRITE "\hline" _n
$WRITE "  Model        &    (1)   & (2)  & (3)    \\" _n
$WRITE "\hline" _n
$WRITE  "Effect of Mothers'   & "  %9.2f ( $pe11 ) " & " %9.2f ( $pe12 ) " & "  %9.2f ( $pe13 )  " \\" _n
$WRITE  "DACA Eligibility  & ("  %9.2f ( $se11 ) ") & (" %9.2f ( $se12 ) ") & ("  %9.2f ( $se13 )  ") \\" _n
$WRITE "\hline" _n
$WRITE  "Number of children & "  %9.0f ( $obs1 ) " & " %9.0f ( $obs2 ) " & " %9.0f ($obs3) " \\ " _n
$WRITE  "Optimal bandwidth ($\pm$ days) & "  %9.0f ( $bw1 ) " & " %9.0f ( $bw2 ) " & "  %9.0f ( $bw3 )  " \\" _n
$WRITE "    \hline \hline" _n
$WRITE "\multicolumn{4}{p{0.8\textwidth}}{\scriptsize Regression coefficients from local linear regression shown with robust standard errors (clustered by mother) in parentheses. The estimation samples are determined by an adaptive mean-squared error optimal bandwidth selection. All models include the distance variable and its interaction with the DACA eligibility indicator. The outcome variables are coded as 0 or 100 such that the effect estimates of the regression coefficients are measured in percentage points. See text for details.}" _n
$WRITE "    \end{tabular} " _n
$WRITE " \end{table} " _n
file close myfile

* save results for plot of Fig 2
cd  "$path/daca_oregon_notshared/results/"
matlist res
mat2txt , matrix(res) saving(res_fig2.txt) replace


/////// Table S.1: Descriptive Statistics for Sample of Children of Unauthorized Mothers
label var y_300308309 "Adjustment or Anxiety Disorder"
label var y_300308309_p "Adjustment or Anxiety Disorder"

label var y_308309 "Adjustment Disorder"
label var y_308309_p "Adjustment Disorder"

label var y_300 "Anxiety Disorder"
label var y_300_p "Anxiety Disorder"

label var y_visitop "No. of Outpatient Visits"
label var y_visitop_p "No. of Outpatient Visits"

label var y_visiter "No. of Emergency Room and Urgent Care Visits"
label var y_visiter_p "No. of Emergency Room and Urgent Care Visits"

label var y_visit "No. of Total Visits"
label var y_visit_p "No. of Total Visits"

label var mother_yob  "Year of Birth"
label var rvd  "Distance of Birthday from Cutoff Date (days)"
label var xxethnhis "$\,$  Not hispanic"
label var xxethhis "$\,$  Hispanic"
label var xxethdk "$\,$  Unkown"
label var racecat1 "$\,$  White"
label var racecat2 "$\,$  Asian"
label var racecat3 "$\,$  Black"
label var racecat4 "$\,$  Hispanic"
label var racecat5 "$\,$  American Indian"
label var racecat6 "$\,$  Other"

* Post-DACA Outcomes
global Yvars1  = "y_300308309 y_308309 y_300  y_visit y_visitop y_visiter"

* Pre-DACA Vars
global Yvars2a = "y_300308309_p y_308309_p y_300_p y_visit_p y_visitop_p y_visiter_p"
global Yvars2b = "yob mob age2015 female"
global Yvars2c = "xxethhis xxethnhis xxethdk"
global Yvars2d = "racecat6 racecat1 racecat4 racecat2 racecat3  racecat5 "
global Yvars3  = "mother_yob rvd"

cd "/Users/jhainmueller/Dropbox (IPL)/daca_oregon/draft/Science/tables"
cap file close myfile
file open myfile using tabS1.tex, write replace
global WRITE file write myfile
$WRITE "\begin{table}[!hbt]" _n
$WRITE "  \centering" _n
$WRITE "  \small" _n
$WRITE "  \caption{Descriptive Statistics for Sample of Children of Unauthorized Mothers}\label{tab:S1}" _n
$WRITE "    \begin{tabular}{lccc}" _n
$WRITE "    \hline \hline" _n
$WRITE "          &    Mean & SD & Obs    \\" _n
$WRITE "\hline" _n
$WRITE "Post-DACA Period (2013-2015): \\" _n
$WRITE "\hline" _n
foreach dv of varlist $Yvars1  {

sum `dv'  if tag1 & mother_CWCX==1
global  Obs1 = `r(N)'
global rmean1 = `r(mean)'
global rsd1 = `r(sd)'
local foo : variable label `dv'

$WRITE  " `foo' & "  %9.2f ( $rmean1 ) " & " %9.2f ( $rsd1 ) " & "  %9.0f ( $Obs1 )  " \\" _n

}
$WRITE "\hline" _n
$WRITE "Pre-DACA Period (2003-2012): \\" _n
$WRITE "\hline" _n
foreach dv of varlist $Yvars2a  {

sum `dv'  if tag1 & mother_CWCX==1
global  Obs1 = `r(N)'
global rmean1 = `r(mean)'
global rsd1 = `r(sd)'
local foo : variable label `dv'
$WRITE  " `foo' & "  %9.2f ( $rmean1 ) " & " %9.2f ( $rsd1 ) " & "  %9.0f ( $Obs1 )  " \\" _n
}
$WRITE "\hline" _n
$WRITE "Time-invariant: \\" _n
$WRITE "\hline" _n
foreach dv of varlist $Yvars2b  {
sum `dv'  if tag1 & mother_CWCX==1
global  Obs1 = `r(N)'
global rmean1 = `r(mean)'
global rsd1 = `r(sd)'
local foo : variable label `dv'
$WRITE  " `foo' & "  %9.2f ( $rmean1 ) " & " %9.2f ( $rsd1 ) " & "  %9.0f ( $Obs1 )  " \\" _n
}


$WRITE "Ethnicity: \\" _n
foreach dv of varlist $Yvars2c  {
sum `dv'  if tag1 & mother_CWCX==1
global  Obs1 = `r(N)'
global rmean1 = `r(mean)'
global rsd1 = `r(sd)'
local foo : variable label `dv'
$WRITE  " `foo' & "  %9.2f ( $rmean1 ) " & " %9.2f ( $rsd1 ) " & "  %9.0f ( $Obs1 )  " \\" _n
}

$WRITE "Race: \\" _n
foreach dv of varlist $Yvars2d  {
sum `dv'  if tag1 & mother_CWCX==1
global  Obs1 = `r(N)'
global rmean1 = `r(mean)'
global rsd1 = `r(sd)'
local foo : variable label `dv'
$WRITE  " `foo' & "  %9.2f ( $rmean1 ) " & " %9.2f ( $rsd1 ) " & "  %9.0f ( $Obs1 )  " \\" _n
}

$WRITE "\hline" _n
$WRITE "Mother: \\" _n
$WRITE "\hline" _n
foreach dv of varlist $Yvars3  {

sum `dv'  if tag1 & mother_CWCX==1
global  Obs1 = `r(N)'
global rmean1 = `r(mean)'
global rsd1 = `r(sd)'
local foo : variable label `dv'

$WRITE  " `foo' & "  %9.2f ( $rmean1 ) " & " %9.2f ( $rsd1 ) " & "  %9.0f ( $Obs1 )  " \\" _n

}

$WRITE "    \hline \hline" _n
$WRITE "\multicolumn{4}{p{0.75\textwidth}}{\scriptsize Sample consists of children who are born to mothers who utilized Emergency Medicaid for delivery during the 2003-2015 period. Post-DACA period is from 2013 to 2015. Pre-DACA period is from 2003 to 2012 (including only the first two quarters of 2012). Binary variables are codeded as 0 or 100 such that the summary statitsics are in percentage points.}" _n
$WRITE "    \end{tabular} " _n
$WRITE " \end{table} " _n
file close myfile


//// Table S.2: Diagnoses (ICD 9) in the Post-DACA Period 

eststo clear
eststo: estpost sum y_any30000	y_any30001	y_any30002	y_any30009	y_any30011	y_any30019	y_any30020	y_any30021	///
y_any30023	y_any30029	y_any3003	y_any3004	y_any3007	y_any30081	y_any30082	y_any3009	///
y_any3080	y_any3081	y_any3082	y_any3083	y_any3084	y_any3089	y_any3090	y_any3091	///
y_any30921	y_any30923	y_any30924	y_any30928	y_any30929	y_any3093	y_any3094	y_any30981	///
y_any30982	y_any30989	y_any3099	if mother_CWCX==1

cd "/Users/jhainmueller/Dropbox (IPL)/daca_oregon/draft/Science/tables"
esttab using "sumstat_sub.tex", replace   wide  cells("mean(fmt(2)) sd(fmt(2)) count(fmt(0))") nonotes  label noobs fragment title("ICD 9 Codes in the Post-DACA Period") nonum nomtitle collabel(Mean SD Obs) ///
varlabels(,blist(y_any30000 "300. \hspace{4mm}Anxiety, dissociative and somatoform disorders \\ \hline " y_any3080 "\hline  308. \hspace{4mm}Acute Reaction to Stress\\ \hline " y_any3090 "\hline 309. \hspace{4mm}Adjustment Reaction \\ \hline ")) 


//// Table S.3: Regression Discontinuity Design Estimates: Placebo Effects of Mothers’ DACA Eligibility on Children’s Background Characteristics
capture matrix drop res
eststo clear
foreach y of varlist y_visitop_p y_visiter_p y_visit_p yob mob female  {
rdbwselect `y' rvd         if mother_CWCX==1 , vce(cluster clid)  
scalar bw1 = `e(h_mserd)'
eststo: reg `y' Z##c.rvd   if mother_CWCX==1 & bwd<=`e(h_mserd)', cl(mother_SAK_RECIP)
estadd scalar bw = bw1
}
cd "/Users/jhainmueller/Dropbox (IPL)/daca_oregon/draft/Science/tables"
esttab using tabS3.tex,  replace tex label  keep(1.Z) scalars(bw) b(2) se(2)  sfmt(0) coeflabels(1.Z "Effect of Mothers' ") nolegend ///
prehead("\begin{table}\small  \caption{\bf{Regression Discontinuity Design Estimates: Effects of Mothers' DACA Eligibility on Children's Background Characteristics} \label{tab:S3}} \scriptsize  \begin{tabular}{lcccccc} \hline \hline") ///
postfoot("\hline \hline \multicolumn{7}{p{1\textwidth}}{\scriptsize Regression coefficients from local linear regression shown with robust standard errors (clustered by mother) in parentheses. The estimation samples are determined by an adaptive mean-squared error optimal bandwidth selection. All models include the distance variable and its interaction with the DACA eligibility indicator. The binary variables are coded as 0 or 100 such that the effect estimates of the regression coefficients are measured in percentage points. See text for details. }     \end{tabular}  \end{table} ")

//// Table S.4: Regression Discontinuity Design Estimates: Placebo Effects of Mothers’ DACA Eligibility on Children’s Background Characteristics
capture matrix drop res
eststo clear
foreach y of varlist xxethnhis xxethhis xxethdk racecat* age2015   {
rdbwselect `y' rvd         if mother_CWCX==1 , vce(cluster clid)  
scalar bw1 = `e(h_mserd)'
eststo: reg `y' Z##c.rvd   if mother_CWCX==1 & bwd<=`e(h_mserd)', cl(mother_SAK_RECIP)
estadd scalar bw = bw1
}
cd "/Users/jhainmueller/Dropbox (IPL)/daca_oregon/draft/Science/tables"
esttab using tabS4.tex,  replace tex label  keep(1.Z) scalars(bw) b(2) se(2)  sfmt(0) coeflabels(1.Z "Effect of Mothers' ") nolegend ///
prehead("\begin{table}\small  \caption{\bf{Regression Discontinuity Design Estimates: Effects of Mothers' DACA Eligibility on Children's Background Characteristics} \label{tab:S4}} \scriptsize     \begin{tabular}{lcccccccccc} \hline \hline") ///
postfoot("\hline \hline \multicolumn{11}{p{1\textwidth}}{\scriptsize Regression coefficients from local linear regression shown with robust standard errors (clustered by mother) in parentheses. The estimation samples are determined by an adaptive mean-squared error optimal bandwidth selection. All models include the distance variable and its interaction with the DACA eligibility indicator. The binary variables are coded as 0 or 100 such that the effect estimates of the regression coefficients are measured in percentage points. See text for details. }     \end{tabular}  \end{table} ")


//// Fig. S.2: Test for Sorting Around the Birthdate Cutoff

* first test using first method
rddensity rvd if mother_CWCX==1

* second test with McCrathy method
DCdensity rvd if mother_CWCX==1 & rvd>-250 & rvd<250, breakpoint(0) generate(Xj Yj r0 fhat se_fhat) 

cd  "$path/daca_oregon_notshared/results/"
preserve
keep    Xj Yj r0 fhat se_fhat
saveold res_figS2.dta , version(11) replace 
restore

//// Fig. S.4: Effect of Mothers’ DACA Eligibility on Children’s Mental Health. Sensitivity to Bandwith.
global yvars = "y_300308309 y_308309 y_300"
cap drop estimate upper lower bandwidth
foreach y of global yvars {
 matrix B = J(600,4,.)
  forvalues i = 100/200{
		reg `y' Z##c.rvd if tag1 & mother_CWCX==1 & bwd <= `i', cl(mother_SAK_RECIP)
		matrix B[`i',1] = _b[1.Z]
		matrix B[`i',2] = _b[1.Z] + 1.96*_se[1.Z]
		matrix B[`i',3] = _b[1.Z] - 1.96*_se[1.Z]
		matrix B[`i',4] = `i'
  } 
 mat2txt , matrix(B) saving("res_figS4_`y'.txt") replace
}


//// Fig. S.5: Effect of Mothers’ DACA Eligibility on Children’s Mental Health Outcomes (Bias-Corrected Local Polynomial Estimator).
capture matrix drop res
cap local drop counter
local counter = 1
global yvars = "y_300308309 y_308309 y_300"
foreach y of global yvars {
rdrobust `y' rvd  if mother_CWCX==1 , vce(cluster clid)
matrix coefse =  `e(tau_cl)' , `e(ci_rb)'
matrix rownames coefse = "`y'"
matlist coefse
mat res = nullmat(res) \ coefse
global bw`counter' = `e(h_l)'
global pe1`counter' = `e(tau_bc)'
global se1`counter' = `e(se_tau_rb)'
global obs`counter' = `e(N_h_l)' + `e(N_h_r)'
local counter = `counter' + 1
di "`counter'"
}
cd  "$path/daca_oregon_notshared/results/"
matlist res
mat2txt , matrix(res) saving(res_figS5.txt) replace

//// Table S.7: Regression Discontinuity Design Estimates: Effect of Mothers’ DACA Eligibility on Children’s Mental Health (Bias-Corrected Local Polynomial Estimator)
cd "/Users/jhainmueller/Dropbox (IPL)/daca_oregon/draft/Science/tables"
cap file close myfile
file open myfile using tabS7.tex, write replace
global WRITE file write myfile
$WRITE "\begin{table}[!hbt]" _n
$WRITE "  \centering" _n
$WRITE "  \small" _n
$WRITE "  \caption{\bf Regression Discontinuity Design Estimates: Effect of Mothers' DACA Eligibility on Children's Mental Health (Bias-Corrected Local Polynomial Estimator)}\label{tab:S7}" _n
$WRITE "    \begin{tabular}{lccc}" _n
$WRITE "    \hline \hline" _n
$WRITE "          &    Adjustment or  & Adjustment  & Anxiety    \\" _n
$WRITE " Outcome         &    Anxiety Disorder      & Disorder & Disorder    \\" _n
$WRITE "\hline" _n
$WRITE "  Model        &    (1)   & (2)  & (3)    \\" _n
$WRITE "\hline" _n
$WRITE  "Effect of Mothers'   & "  %9.2f ( $pe11 ) " & " %9.2f ( $pe12 ) " & "  %9.2f ( $pe13 )  " \\" _n
$WRITE  "DACA Eligibility  & ("  %9.2f ( $se11 ) ") & (" %9.2f ( $se12 ) ") & ("  %9.2f ( $se13 )  ") \\" _n
$WRITE "\hline" _n
$WRITE  "Number of children & "  %9.0f ( $obs1 ) " & " %9.0f ( $obs2 ) " & " %9.0f ($obs3) " \\ " _n
$WRITE  "Optimal bandwidth ($\pm$ days) & "  %9.0f ( $bw1 ) " & " %9.0f ( $bw2 ) " & "  %9.0f ( $bw3 )  " \\" _n
$WRITE "    \hline \hline" _n
$WRITE "\multicolumn{4}{p{0.8\textwidth}}{\scriptsize Regression coefficients from bias-corrected local polynomial estimator shown with robust standard errors (clustered by mother) in parentheses. The estimation samples are determined by an adaptive mean-squared error optimal bandwidth selection. The outcome variables are coded as 0 or 100 such that the effect estimates of the regression coefficients are measured in percentage points. See text for details.}" _n
$WRITE "    \end{tabular} " _n
$WRITE " \end{table} " _n
file close myfile




//// Fig. S.6: Effect of Mothers’ DACA Eligibility on Children’s Mental Health (Children Born Before DACA).
global yvars = "y_300308309 y_308309 y_300"
capture matrix drop res
cap local drop counter
local counter = 1
foreach y of global yvars {
rdbwselect `y' rvd  if mother_CWCX==1 & yob<=2012, vce(cluster clid)
global bw`counter' = `e(h_mserd)'
reg `y' Z##c.rvd   if mother_CWCX==1 & bwd<=`e(h_mserd)' & yob<=2012, cl(mother_SAK_RECIP)
global pe1`counter' = _b[1.Z]
global se1`counter' = _se[1.Z]
global ppe`counter' =  (_b[1.Z] / _b[_cons])*100
global pe2`counter' = _b[_cons]
global se2`counter' = _se[_cons]
global obs`counter' = `e(N)'
local counter = `counter' + 1
di "`counter'"
matrix coefse = _b[1.Z] , _se[1.Z]
matrix rownames coefse = "`y'"
matlist coefse
mat res = nullmat(res) \ coefse
}
cd  "$path/daca_oregon_notshared/results/"
matlist res
mat2txt , matrix(res) saving(res_figS6.txt) replace

//// Table S.8: Regression Discontinuity Design Estimates: Effect of Mothers’ DACA Eligibility on Children’s Mental Health (Children Born Before DACA)
cd "/Users/jhainmueller/Dropbox (IPL)/daca_oregon/draft/Science/tables"
cap file close myfile
file open myfile using tabS8.tex, write replace
global WRITE file write myfile
$WRITE "\begin{table}[!hbt]" _n
$WRITE "  \centering" _n
$WRITE "  \small" _n
$WRITE "  \caption{\bf Regression Discontinuity Design Estimates: Effect of Mothers' DACA Eligibility on Children's Mental Health (Children Born Before DACA)}\label{tab:S8}" _n
$WRITE "    \begin{tabular}{lccc}" _n
$WRITE "    \hline \hline" _n
$WRITE "          &    Adjustment or  & Adjustment  & Anxiety    \\" _n
$WRITE " Outcome         &    Anxiety Disorder      & Disorder & Disorder    \\" _n
$WRITE "\hline" _n
$WRITE "  Model        &    (1)   & (2)  & (3)    \\" _n
$WRITE "\hline" _n
$WRITE  "Effect of Mothers'   & "  %9.2f ( $pe11 ) " & " %9.2f ( $pe12 ) " & "  %9.2f ( $pe13 )  " \\" _n
$WRITE  "DACA Eligibility  & ("  %9.2f ( $se11 ) ") & (" %9.2f ( $se12 ) ") & ("  %9.2f ( $se13 )  ") \\" _n
$WRITE "\hline" _n
$WRITE  "Number of children & "  %9.0f ( $obs1 ) " & " %9.0f ( $obs2 ) " & " %9.0f ($obs3) " \\ " _n
$WRITE  "Optimal bandwidth ($\pm$ days) & "  %9.0f ( $bw1 ) " & " %9.0f ( $bw2 ) " & "  %9.0f ( $bw3 )  " \\" _n
$WRITE "\hline" _n
$WRITE  "Percent change ($100\,(\frac{\hat{\tau}}{\hat{\alpha}}$)) & "  %9.2f ( $ppe1 ) " & " %9.2f ( $ppe2 ) " & "  %9.2f ( $ppe3 )  " \\" _n
$WRITE "    \hline \hline" _n
$WRITE "\multicolumn{4}{p{0.8\textwidth}}{\scriptsize Regression coefficients from local linear regression shown with robust standard errors (clustered by mother) in parentheses. The estimation samples are determined by an adaptive mean-squared error optimal bandwidth selection. All models include the distance variable and its interaction with the DACA eligibility indicator. The outcome variables are coded as 0 or 100 such that the effect estimates of the regression coefficients are measured in percentage points. The percent change in the last row is computed as $100\,(\frac{\hat{\tau}}{\hat{\alpha}}$) and measures at the DACA birthdate cutoff the effect of mothers' DACA elegibility ($\hat{\tau}$) divided by the estimated average diagnoses rate for children of ineligible mothers ($\hat{\alpha}$). See text for details.}" _n
$WRITE "    \end{tabular} " _n
$WRITE " \end{table} " _n
file close myfile


//// Fig. S.7: Effect of Mothers’ DACA Eligibility on Children’s Mental Health (Post-DACA Period Including Q3 and Q4 2012).
global yvars = "y_300308309_b y_308309_b y_300_b"
capture matrix drop res
cap local drop counter
local counter = 1
foreach y of global yvars {
rdbwselect `y' rvd  if mother_CWCX==1 & yob<=2012, vce(cluster clid)
global bw`counter' = `e(h_mserd)'
reg `y' Z##c.rvd   if mother_CWCX==1 & bwd<=`e(h_mserd)' & yob<=2012, cl(mother_SAK_RECIP)
global pe1`counter' = _b[1.Z]
global se1`counter' = _se[1.Z]
global ppe`counter' =  (_b[1.Z] / _b[_cons])*100
global pe2`counter' = _b[_cons]
global se2`counter' = _se[_cons]
global obs`counter' = `e(N)'
local counter = `counter' + 1
matrix coefse = _b[1.Z] , _se[1.Z]
matrix rownames coefse = "`y'"
matlist coefse
mat res = nullmat(res) \ coefse
}
cd  "$path/daca_oregon_notshared/results/"
matlist res
mat2txt , matrix(res) saving(res_figS7.txt) replace

//// Table S.9: Regression Discontinuity Design Estimates: Effect of Mothers’ DACA Eligibility on Children’s Mental Health (Post-DACA Period Including Q3 and Q4 2012))
cd "/Users/jhainmueller/Dropbox (IPL)/daca_oregon/draft/Science/tables"
cap file close myfile
file open myfile using tabS9.tex, write replace
global WRITE file write myfile
$WRITE "\begin{table}[!hbt]" _n
$WRITE "  \centering" _n
$WRITE "  \small" _n
$WRITE "  \caption{\bf Regression Discontinuity Design Estimates: Effect of Mothers' DACA Eligibility on Children's Mental Health (Post-DACA Period Including Q3 and Q4 of 2012)}\label{tab:S9}" _n
$WRITE "    \begin{tabular}{lccc}" _n
$WRITE "    \hline \hline" _n
$WRITE "          &    Adjustment or  & Adjustment  & Anxiety    \\" _n
$WRITE " Outcome         &    Anxiety Disorder      & Disorder & Disorder    \\" _n
$WRITE "\hline" _n
$WRITE "  Model        &    (1)   & (2)  & (3)    \\" _n
$WRITE "\hline" _n
$WRITE  "Effect of Mothers'   & "  %9.2f ( $pe11 ) " & " %9.2f ( $pe12 ) " & "  %9.2f ( $pe13 )  " \\" _n
$WRITE  "DACA Eligibility  & ("  %9.2f ( $se11 ) ") & (" %9.2f ( $se12 ) ") & ("  %9.2f ( $se13 )  ") \\" _n
$WRITE "\hline" _n
$WRITE  "Number of children & "  %9.0f ( $obs1 ) " & " %9.0f ( $obs2 ) " & " %9.0f ($obs3) " \\ " _n
$WRITE  "Optimal bandwidth ($\pm$ days) & "  %9.0f ( $bw1 ) " & " %9.0f ( $bw2 ) " & "  %9.0f ( $bw3 )  " \\" _n
$WRITE "\hline" _n
$WRITE  "Percent change ($100\,(\frac{\hat{\tau}}{\hat{\alpha}}$)) & "  %9.2f ( $ppe1 ) " & " %9.2f ( $ppe2 ) " & "  %9.2f ( $ppe3 )  " \\" _n
$WRITE "    \hline \hline" _n
$WRITE "\multicolumn{4}{p{0.8\textwidth}}{\scriptsize Regression coefficients from local linear regression shown with robust standard errors (clustered by mother) in parentheses. The estimation samples are determined by an adaptive mean-squared error optimal bandwidth selection. All models include the distance variable and its interaction with the DACA eligibility indicator. The outcome variables are coded as 0 or 100 such that the effect estimates of the regression coefficients are measured in percentage points. The percent change in the last row is computed as $100\,(\frac{\hat{\tau}}{\hat{\alpha}}$) and measures at the DACA birthdate cutoff the effect of mothers' DACA elegibility ($\hat{\tau}$) divided by the estimated average diagnoses rate for children of ineligible mothers ($\hat{\alpha}$). See text for details.}" _n
$WRITE "    \end{tabular} " _n
$WRITE " \end{table} " _n
file close myfile

//// Fig. S.8: Effect of Mothers’ DACA Eligibility on Children’s Mental Health (Alternative Definitions of Mental Health Outcomes).
global yvars = "y_dsmadjacu y_dsmadj y_dsmanx"
capture matrix drop res
cap local drop counter
local counter = 1
foreach y of global yvars {
rdbwselect `y' rvd  if mother_CWCX==1 & yob<=2012, vce(cluster clid)
global bw`counter' = `e(h_mserd)'
reg `y' Z##c.rvd   if mother_CWCX==1 & bwd<=`e(h_mserd)' & yob<=2012, cl(mother_SAK_RECIP)
global pe1`counter' = _b[1.Z]
global se1`counter' = _se[1.Z]
global ppe`counter' =  (_b[1.Z] / _b[_cons])*100
global pe2`counter' = _b[_cons]
global se2`counter' = _se[_cons]
global obs`counter' = `e(N)'
local counter = `counter' + 1
matrix coefse = _b[1.Z] , _se[1.Z]
matrix rownames coefse = "`y'"
matlist coefse
mat res = nullmat(res) \ coefse
}
cd  "$path/daca_oregon_notshared/results/"
matlist res
mat2txt , matrix(res) saving(res_figS8.txt) replace


//// Table S.10: Regression Discontinuity Design Estimates: Effect of Mothers’ DACA Eligibility on Children’s Mental Health (Alternative Definitions of Mental Health Outcomes)
cd "/Users/jhainmueller/Dropbox (IPL)/daca_oregon/draft/Science/tables"
cap file close myfile
file open myfile using tabS10.tex, write replace
global WRITE file write myfile
$WRITE "\begin{table}[!hbt]" _n
$WRITE "  \centering" _n
$WRITE "  \small" _n
$WRITE "  \caption{\bf Regression Discontinuity Design Estimates: Effect of Mothers' DACA Eligibility on Children's Mental Health (Alternative Definitions of Mental Health Outcomes)}\label{tab:S10}" _n
$WRITE "    \begin{tabular}{lccc}" _n
$WRITE "    \hline \hline" _n
$WRITE "                 &    Adjustment or              & Adjustment  & Anxiety    \\" _n
$WRITE " Outcome         &    Acute Stress  Disorder      & Disorder  & Disorder    \\" _n
$WRITE "\hline" _n
$WRITE "  Model        &    (1)   & (2)  & (3)    \\" _n
$WRITE "\hline" _n
$WRITE  "Effect of Mothers'   & "  %9.2f ( $pe11 ) " & " %9.2f ( $pe12 ) " & "  %9.2f ( $pe13 )  " \\" _n
$WRITE  "DACA Eligibility  & ("  %9.2f ( $se11 ) ") & (" %9.2f ( $se12 ) ") & ("  %9.2f ( $se13 )  ") \\" _n
$WRITE "\hline" _n
$WRITE  "Number of children & "  %9.0f ( $obs1 ) " & " %9.0f ( $obs2 ) " & " %9.0f ($obs3) " \\ " _n
$WRITE  "Optimal bandwidth ($\pm$ days) & "  %9.0f ( $bw1 ) " & " %9.0f ( $bw2 ) " & "  %9.0f ( $bw3 )  " \\" _n
$WRITE "\hline" _n
$WRITE  "Percent change ($100\,(\frac{\hat{\tau}}{\hat{\alpha}}$)) & "  %9.2f ( $ppe1 ) " & " %9.2f ( $ppe2 ) " & "  %9.2f ( $ppe3 )  " \\" _n
$WRITE "    \hline \hline" _n
$WRITE "\multicolumn{4}{p{0.8\textwidth}}{\scriptsize Regression coefficients from local linear regression shown with robust standard errors (clustered by mother) in parentheses. The estimation samples are determined by an adaptive mean-squared error optimal bandwidth selection. All models include the distance variable and its interaction with the DACA eligibility indicator. The outcome variables are coded as 0 or 100 such that the effect estimates of the regression coefficients are measured in percentage points. The percent change in the last row is computed as $100\,(\frac{\hat{\tau}}{\hat{\alpha}}$) and measures at the DACA birthdate cutoff the effect of mothers' DACA elegibility ($\hat{\tau}$) divided by the estimated average diagnoses rate for children of ineligible mothers ($\hat{\alpha}$). See text for details.}" _n
$WRITE "    \end{tabular} " _n
$WRITE " \end{table} " _n
file close myfile



//// Fig. S.9: Effect of Mothers’ DACA Eligibility on Children’s Mental Health by Child Age
global yvars = "y_300308309 y_308309 y_300"
recode age (0/5=0) (6/12=1) , gen(youngold)
capture matrix drop res
forvalues i = 0/1 {
foreach y of global yvars {
rdbwselect `y' rvd  if mother_CWCX==1 & youngold==`i', vce(cluster clid)
reg `y' Z##c.rvd   if mother_CWCX==1 & youngold==`i' & bwd<=`e(h_mserd)', cl(mother_SAK_RECIP)
matrix coefse = _b[1.Z] , _se[1.Z] , `i'
matrix rownames coefse = "`y'"
matlist coefse
mat res = nullmat(res) \ coefse
 }
}
cd  "$path/daca_oregon_notshared/results/"
matlist res
mat2txt , matrix(res) saving(res_figS9.txt) replace

//// Table S.11: Regression Discontinuity Design Estimates: Effect of Mothers’ DACA Eligibility on Children’s Mental Health (Children Age 0-5)
global yvars = "y_300308309 y_308309 y_300"
capture matrix drop res
cap local drop counter
local counter = 1
foreach y of global yvars {
rdbwselect `y' rvd  if mother_CWCX==1 & youngold==0, vce(cluster clid)
global bw`counter' = `e(h_mserd)'
reg `y' Z##c.rvd   if mother_CWCX==1 & bwd<=`e(h_mserd)' & youngold==0, cl(mother_SAK_RECIP)
global pe1`counter' = _b[1.Z]
global se1`counter' = _se[1.Z]
global ppe`counter' =  (_b[1.Z] / _b[_cons])*100
global pe2`counter' = _b[_cons]
global se2`counter' = _se[_cons]
global obs`counter' = `e(N)'
local counter = `counter' + 1
di "`counter'"
}

cd "/Users/jhainmueller/Dropbox (IPL)/daca_oregon/draft/Science/tables"
cap file close myfile
file open myfile using tabS11.tex, write replace
global WRITE file write myfile
$WRITE "\begin{table}[!hbt]" _n
$WRITE "  \centering" _n
$WRITE "  \small" _n
$WRITE "  \caption{\bf Regression Discontinuity Design Estimates: Effect of Mothers' DACA Eligibility on Children's Mental Health (Children Age 0-5)}\label{tab:S11}" _n
$WRITE "    \begin{tabular}{lccc}" _n
$WRITE "    \hline \hline" _n
$WRITE "          &    Adjustment or  & Adjustment  & Anxiety    \\" _n
$WRITE " Outcome         &    Anxiety Disorder      & Disorder & Disorder    \\" _n
$WRITE "\hline" _n
$WRITE "  Model        &    (1)   & (2)  & (3)    \\" _n
$WRITE "\hline" _n
$WRITE  "Effect of Mothers'   & "  %9.2f ( $pe11 ) " & " %9.2f ( $pe12 ) " & "  %9.2f ( $pe13 )  " \\" _n
$WRITE  "DACA Eligibility  & ("  %9.2f ( $se11 ) ") & (" %9.2f ( $se12 ) ") & ("  %9.2f ( $se13 )  ") \\" _n
$WRITE "\hline" _n
$WRITE  "Number of children & "  %9.0f ( $obs1 ) " & " %9.0f ( $obs2 ) " & " %9.0f ($obs3) " \\ " _n
$WRITE  "Optimal bandwidth ($\pm$ days) & "  %9.0f ( $bw1 ) " & " %9.0f ( $bw2 ) " & "  %9.0f ( $bw3 )  " \\" _n
$WRITE "\hline" _n
$WRITE  "Percent change ($100\,(\frac{\hat{\tau}}{\hat{\alpha}}$)) & "  %9.2f ( $ppe1 ) " & " %9.2f ( $ppe2 ) " & "  %9.2f ( $ppe3 )  " \\" _n
$WRITE "    \hline \hline" _n
$WRITE "\multicolumn{4}{p{0.8\textwidth}}{\scriptsize Regression coefficients from local linear regression shown with robust standard errors (clustered by mother) in parentheses. The estimation samples are determined by an adaptive mean-squared error optimal bandwidth selection. All models include the distance variable and its interaction with the DACA eligibility indicator. The outcome variables are coded as 0 or 100 such that the effect estimates of the regression coefficients are measured in percentage points. The percent change in the last row is computed as $100\,(\frac{\hat{\tau}}{\hat{\alpha}}$) and measures at the DACA birthdate cutoff the effect of mothers' DACA elegibility ($\hat{\tau}$) divided by the estimated average diagnoses rate for children of ineligible mothers ($\hat{\alpha}$). See text for details.}" _n
$WRITE "    \end{tabular} " _n
$WRITE " \end{table} " _n
file close myfile

//// Table S.12: Regression Discontinuity Design Estimates: Effect of Mothers’ DACA Eligibility on Children’s Mental Health (Children Age 6-12)
global yvars = "y_300308309 y_308309 y_300"
capture matrix drop res
cap local drop counter
local counter = 1
foreach y of global yvars {
rdbwselect `y' rvd  if mother_CWCX==1 & youngold==1, vce(cluster clid)
global bw`counter' = `e(h_mserd)'
reg `y' Z##c.rvd   if mother_CWCX==1 & bwd<=`e(h_mserd)' & youngold==1, cl(mother_SAK_RECIP)
global pe1`counter' = _b[1.Z]
global se1`counter' = _se[1.Z]
global ppe`counter' =  (_b[1.Z] / _b[_cons])*100
global pe2`counter' = _b[_cons]
global se2`counter' = _se[_cons]
global obs`counter' = `e(N)'
local counter = `counter' + 1
di "`counter'"
}

cd "/Users/jhainmueller/Dropbox (IPL)/daca_oregon/draft/Science/tables"
cap file close myfile
file open myfile using tabS12.tex, write replace
global WRITE file write myfile
$WRITE "\begin{table}[!hbt]" _n
$WRITE "  \centering" _n
$WRITE "  \small" _n
$WRITE "  \caption{\bf Regression Discontinuity Design Estimates: Effect of Mothers' DACA Eligibility on Children's Mental Health (Children Age 6-12)}\label{tab:S12}" _n
$WRITE "    \begin{tabular}{lccc}" _n
$WRITE "    \hline \hline" _n
$WRITE "          &    Adjustment or  & Adjustment  & Anxiety    \\" _n
$WRITE " Outcome         &    Anxiety Disorder      & Disorder & Disorder    \\" _n
$WRITE "\hline" _n
$WRITE "  Model        &    (1)   & (2)  & (3)    \\" _n
$WRITE "\hline" _n
$WRITE  "Effect of Mothers'   & "  %9.2f ( $pe11 ) " & " %9.2f ( $pe12 ) " & "  %9.2f ( $pe13 )  " \\" _n
$WRITE  "DACA Eligibility  & ("  %9.2f ( $se11 ) ") & (" %9.2f ( $se12 ) ") & ("  %9.2f ( $se13 )  ") \\" _n
$WRITE "\hline" _n
$WRITE  "Number of children & "  %9.0f ( $obs1 ) " & " %9.0f ( $obs2 ) " & " %9.0f ($obs3) " \\ " _n
$WRITE  "Optimal bandwidth ($\pm$ days) & "  %9.0f ( $bw1 ) " & " %9.0f ( $bw2 ) " & "  %9.0f ( $bw3 )  " \\" _n
$WRITE "\hline" _n
$WRITE  "Percent change ($100\,(\frac{\hat{\tau}}{\hat{\alpha}}$)) & "  %9.2f ( $ppe1 ) " & " %9.2f ( $ppe2 ) " & "  %9.2f ( $ppe3 )  " \\" _n
$WRITE "    \hline \hline" _n
$WRITE "\multicolumn{4}{p{0.8\textwidth}}{\scriptsize Regression coefficients from local linear regression shown with robust standard errors (clustered by mother) in parentheses. The estimation samples are determined by an adaptive mean-squared error optimal bandwidth selection. All models include the distance variable and its interaction with the DACA eligibility indicator. The outcome variables are coded as 0 or 100 such that the effect estimates of the regression coefficients are measured in percentage points. The percent change in the last row is computed as $100\,(\frac{\hat{\tau}}{\hat{\alpha}}$) and measures at the DACA birthdate cutoff the effect of mothers' DACA elegibility ($\hat{\tau}$) divided by the estimated average diagnoses rate for children of ineligible mothers ($\hat{\alpha}$). See text for details.}" _n
$WRITE "    \end{tabular} " _n
$WRITE " \end{table} " _n
file close myfile


//// Fig. S.10: Effect of Mothers’ DACA Eligibility on Children’s Mental Health by Child Gender
recode female (100=1) 
global yvars = "y_300308309 y_308309 y_300"
capture matrix drop res
forvalues i = 0/1 {
foreach y of global yvars {
rdbwselect `y' rvd  if mother_CWCX==1 & female==`i', vce(cluster clid)
di "test"
reg `y' Z##c.rvd   if mother_CWCX==1 & female==`i' & bwd<=`e(h_mserd)', cl(mother_SAK_RECIP)
di "test1 `i'"
matrix coefse = _b[1.Z] , _se[1.Z] , `i'
matrix rownames coefse = "`y'"
matlist coefse
mat res = nullmat(res) \ coefse
 }
}

cd  "$path/daca_oregon_notshared/results/"
matlist res
mat2txt , matrix(res) saving(res_figS10.txt) replace

* test for sig difference
reg y_308309 Z##c.rvd##female   if mother_CWCX==1 & bwd<=159, cl(mother_SAK_RECIP)

/// Table S.13: Regression Discontinuity Design Estimates: Effect of Mothers’ DACA Eligibility on Children’s Mental Health (Females)
global yvars = "y_300308309 y_308309 y_300"
capture matrix drop res
cap local drop counter
local counter = 1
foreach y of global yvars {
rdbwselect `y' rvd  if mother_CWCX==1 & female==0, vce(cluster clid)
global bw`counter' = `e(h_mserd)'
reg `y' Z##c.rvd   if mother_CWCX==1 & bwd<=`e(h_mserd)' & female==0, cl(mother_SAK_RECIP)
global pe1`counter' = _b[1.Z]
global se1`counter' = _se[1.Z]
global ppe`counter' =  (_b[1.Z] / _b[_cons])*100
global pe2`counter' = _b[_cons]
global se2`counter' = _se[_cons]
global obs`counter' = `e(N)'
local counter = `counter' + 1
di "`counter'"
}

cd "/Users/jhainmueller/Dropbox (IPL)/daca_oregon/draft/Science/tables"
cap file close myfile
file open myfile using tabS13.tex, write replace
global WRITE file write myfile
$WRITE "\begin{table}[!hbt]" _n
$WRITE "  \centering" _n
$WRITE "  \small" _n
$WRITE "  \caption{\bf Regression Discontinuity Design Estimates: Effect of Mothers' DACA Eligibility on Children's Mental Health (Males)}\label{tab:S13}" _n
$WRITE "    \begin{tabular}{lccc}" _n
$WRITE "    \hline \hline" _n
$WRITE "          &    Adjustment or  & Adjustment  & Anxiety    \\" _n
$WRITE " Outcome         &    Anxiety Disorder      & Disorder & Disorder    \\" _n
$WRITE "\hline" _n
$WRITE "  Model        &    (1)   & (2)  & (3)    \\" _n
$WRITE "\hline" _n
$WRITE  "Effect of Mothers'   & "  %9.2f ( $pe11 ) " & " %9.2f ( $pe12 ) " & "  %9.2f ( $pe13 )  " \\" _n
$WRITE  "DACA Eligibility  & ("  %9.2f ( $se11 ) ") & (" %9.2f ( $se12 ) ") & ("  %9.2f ( $se13 )  ") \\" _n
$WRITE "\hline" _n
$WRITE  "Number of children & "  %9.0f ( $obs1 ) " & " %9.0f ( $obs2 ) " & " %9.0f ($obs3) " \\ " _n
$WRITE  "Optimal bandwidth ($\pm$ days) & "  %9.0f ( $bw1 ) " & " %9.0f ( $bw2 ) " & "  %9.0f ( $bw3 )  " \\" _n
$WRITE "\hline" _n
$WRITE  "Percent change ($100\,(\frac{\hat{\tau}}{\hat{\alpha}}$)) & "  %9.2f ( $ppe1 ) " & " %9.2f ( $ppe2 ) " & "  %9.2f ( $ppe3 )  " \\" _n
$WRITE "    \hline \hline" _n
$WRITE "\multicolumn{4}{p{0.8\textwidth}}{\scriptsize Regression coefficients from local linear regression shown with robust standard errors (clustered by mother) in parentheses. The estimation samples are determined by an adaptive mean-squared error optimal bandwidth selection. All models include the distance variable and its interaction with the DACA eligibility indicator. The outcome variables are coded as 0 or 100 such that the effect estimates of the regression coefficients are measured in percentage points. The percent change in the last row is computed as $100\,(\frac{\hat{\tau}}{\hat{\alpha}}$) and measures at the DACA birthdate cutoff the effect of mothers' DACA elegibility ($\hat{\tau}$) divided by the estimated average diagnoses rate for children of ineligible mothers ($\hat{\alpha}$). See text for details.}" _n
$WRITE "    \end{tabular} " _n
$WRITE " \end{table} " _n
file close myfile

/// Table S.14: Regression Discontinuity Design Estimates: Effect of Mothers’ DACA Eligi- bility on Children’s Mental Health (Males)
global yvars = "y_300308309 y_308309 y_300"
capture matrix drop res
cap local drop counter
local counter = 1
foreach y of global yvars {
rdbwselect `y' rvd  if mother_CWCX==1 & female==1, vce(cluster clid)
global bw`counter' = `e(h_mserd)'
reg `y' Z##c.rvd   if mother_CWCX==1 & bwd<=`e(h_mserd)' & female==1, cl(mother_SAK_RECIP)
global pe1`counter' = _b[1.Z]
global se1`counter' = _se[1.Z]
global ppe`counter' =  (_b[1.Z] / _b[_cons])*100
global pe2`counter' = _b[_cons]
global se2`counter' = _se[_cons]
global obs`counter' = `e(N)'
local counter = `counter' + 1
di "`counter'"
}

cd "/Users/jhainmueller/Dropbox (IPL)/daca_oregon/draft/Science/tables"
cap file close myfile
file open myfile using tabS14.tex, write replace
global WRITE file write myfile
$WRITE "\begin{table}[!hbt]" _n
$WRITE "  \centering" _n
$WRITE "  \small" _n
$WRITE "  \caption{\bf Regression Discontinuity Design Estimates: Effect of Mothers' DACA Eligibility on Children's Mental Health (Females)}\label{tab:S14}" _n
$WRITE "    \begin{tabular}{lccc}" _n
$WRITE "    \hline \hline" _n
$WRITE "          &    Adjustment or  & Adjustment  & Anxiety    \\" _n
$WRITE " Outcome         &    Anxiety Disorder      & Disorder & Disorder    \\" _n
$WRITE "\hline" _n
$WRITE "  Model        &    (1)   & (2)  & (3)    \\" _n
$WRITE "\hline" _n
$WRITE  "Effect of Mothers'   & "  %9.2f ( $pe11 ) " & " %9.2f ( $pe12 ) " & "  %9.2f ( $pe13 )  " \\" _n
$WRITE  "DACA Eligibility  & ("  %9.2f ( $se11 ) ") & (" %9.2f ( $se12 ) ") & ("  %9.2f ( $se13 )  ") \\" _n
$WRITE "\hline" _n
$WRITE  "Number of children & "  %9.0f ( $obs1 ) " & " %9.0f ( $obs2 ) " & " %9.0f ($obs3) " \\ " _n
$WRITE  "Optimal bandwidth ($\pm$ days) & "  %9.0f ( $bw1 ) " & " %9.0f ( $bw2 ) " & "  %9.0f ( $bw3 )  " \\" _n
$WRITE "\hline" _n
$WRITE  "Percent change ($100\,(\frac{\hat{\tau}}{\hat{\alpha}}$)) & "  %9.2f ( $ppe1 ) " & " %9.2f ( $ppe2 ) " & "  %9.2f ( $ppe3 )  " \\" _n
$WRITE "    \hline \hline" _n
$WRITE "\multicolumn{4}{p{0.8\textwidth}}{\scriptsize Regression coefficients from local linear regression shown with robust standard errors (clustered by mother) in parentheses. The estimation samples are determined by an adaptive mean-squared error optimal bandwidth selection. All models include the distance variable and its interaction with the DACA eligibility indicator. The outcome variables are coded as 0 or 100 such that the effect estimates of the regression coefficients are measured in percentage points. The percent change in the last row is computed as $100\,(\frac{\hat{\tau}}{\hat{\alpha}}$) and measures at the DACA birthdate cutoff the effect of mothers' DACA elegibility ($\hat{\tau}$) divided by the estimated average diagnoses rate for children of ineligible mothers ($\hat{\alpha}$). See text for details.}" _n
$WRITE "    \end{tabular} " _n
$WRITE " \end{table} " _n
file close myfile


//// Fig. S.11: Placebo Effect of Medicaid Mothers’ Birthdates on Children’s Mental Health.
global yvars = "y_300308309 y_308309 y_300"
capture matrix drop res
cap local drop counter
local counter = 1
foreach y of global yvars {
rdbwselect `y' rvd  if mother_CWCX==0 , vce(cluster clid)
global bw`counter' = `e(h_mserd)'
reg `y' Z##c.rvd   if mother_CWCX==0 & bwd<=`e(h_mserd)', cl(mother_SAK_RECIP)
global pe1`counter' = _b[1.Z]
global se1`counter' = _se[1.Z]
global ppe`counter' =  (_b[1.Z] / _b[_cons])*100
global pe2`counter' = _b[_cons]
global se2`counter' = _se[_cons]
global obs`counter' = `e(N)'
local counter = `counter' + 1
di "`counter'"
matrix coefse = _b[1.Z] , _se[1.Z]
matrix rownames coefse = "`y'"
matlist coefse
mat res = nullmat(res) \ coefse
}
cd  "$path/daca_oregon_notshared/results/"
matlist res
mat2txt , matrix(res) saving(res_figS11.txt) replace

//// Table S.15: Regression Discontinuity Design Estimates: Placebo Effects on Mental Health for Children of Medicaid Mothers
cd "/Users/jhainmueller/Dropbox (IPL)/daca_oregon/draft/Science/tables"
cap file close myfile
file open myfile using tabS15.tex, write replace
global WRITE file write myfile
$WRITE "\begin{table}[!hbt]" _n
$WRITE "  \centering" _n
$WRITE "  \small" _n
$WRITE "  \caption{\bf Regression Discontinuity Design Estimates: Effect of Medicaid Mothers' Post-Cutoff Birthdates on Children's Mental Health}\label{tab:S15}" _n
$WRITE "    \begin{tabular}{lccc}" _n
$WRITE "    \hline \hline" _n
$WRITE "          &    Adjustment or  & Adjustment  & Anxiety    \\" _n
$WRITE " Outcome         &    Anxiety Disorder      & Disorder & Disorder    \\" _n
$WRITE "\hline" _n
$WRITE "  Model        &    (1)   & (2)  & (3)    \\" _n
$WRITE "\hline" _n
$WRITE  "Effect of Mothers'   & "  %9.2f ( $pe11 ) " & " %9.2f ( $pe12 ) " & "  %9.2f ( $pe13 )  " \\" _n
$WRITE  "Post-Cutoff Birthdates  & ("  %9.2f ( $se11 ) ") & (" %9.2f ( $se12 ) ") & ("  %9.2f ( $se13 )  ") \\" _n
$WRITE "\hline" _n
$WRITE  "Number of children & "  %9.0f ( $obs1 ) " & " %9.0f ( $obs2 ) " & " %9.0f ($obs3) " \\ " _n
$WRITE  "Optimal bandwidth ($\pm$ days) & "  %9.0f ( $bw1 ) " & " %9.0f ( $bw2 ) " & "  %9.0f ( $bw3 )  " \\" _n
$WRITE "    \hline \hline" _n
$WRITE "\multicolumn{4}{p{0.8\textwidth}}{\scriptsize Regression coefficients from local linear regression shown with robust standard errors (clustered by mother) in parentheses. The estimation samples are determined by an adaptive mean-squared error optimal bandwidth selection. All models include the distance variable and its interaction with the DACA eligibility indicator. The outcome variables are coded as 0 or 100 such that the effect estimates of the regression coefficients are measured in percentage points. See text for details.}" _n
$WRITE "    \end{tabular} " _n
$WRITE " \end{table} " _n
file close myfile



///// Fig. S.12: Effect of Mothers’ DACA Eligibility on Children’s Health Care Utilization
global yvars = "y_visitop y_visiter y_visit"
capture matrix drop res
cap local drop counter
local counter = 1
foreach y of global yvars {
rdbwselect `y' rvd  if mother_CWCX==1 , vce(cluster clid)
global bw`counter' = `e(h_mserd)'
reg `y' Z##c.rvd   if mother_CWCX==1 & bwd<=`e(h_mserd)', cl(mother_SAK_RECIP)
matrix coefse = _b[1.Z] , _se[1.Z]
matrix rownames coefse = "`y'"
matlist coefse
mat res = nullmat(res) \ coefse
global pe1`counter' = _b[1.Z]
global se1`counter' = _se[1.Z]
global ppe`counter' =  (_b[1.Z] / _b[_cons])*100
global pe2`counter' = _b[_cons]
global se2`counter' = _se[_cons]
global obs`counter' = `e(N)'
local counter = `counter' + 1
di "`counter'"
}
cd  "$path/daca_oregon_notshared/results/"
matlist res
mat2txt , matrix(res) saving(res_figS12.txt) replace

///// Table S.16: Regression Discontinuity Design Estimates: Effect of Mother’s DACA Eligibility on Children’s Health Care Utilization
cd "/Users/jhainmueller/Dropbox (IPL)/daca_oregon/draft/Science/tables"
cap file close myfile
file open myfile using tabS16.tex, write replace
global WRITE file write myfile
$WRITE "\begin{table}[!hbt]" _n
$WRITE "  \centering" _n
$WRITE "  \small" _n
$WRITE "  \caption{\bf Regression Discontinuity Design Estimates: Effect of Mother's DACA Eligibility on Children's Health Care Utilization}\label{tab:S16}" _n
$WRITE "    \begin{tabular}{lccc}" _n
$WRITE "    \hline \hline" _n
$WRITE "          &    No. of   & No. of & No. of        \\" _n
$WRITE " Outcome         &  Outpatient  Visits      & ER Visits & Total Visits    \\" _n
$WRITE "\hline" _n
$WRITE "  Model        &    (1)   & (2)  & (3)    \\" _n
$WRITE "\hline" _n
$WRITE  "Effect of Mothers'   & "  %9.2f ( $pe11 ) " & " %9.2f ( $pe12 ) " & " %9.2f ( $pe13 )   " \\" _n
$WRITE  "DACA Eligibility  & ("  %9.2f ( $se11 ) ") & (" %9.2f ( $se12 ) ") & (" %9.2f ( $se13 ) ")  \\" _n
$WRITE "\hline" _n
$WRITE  "Number of children & "  %9.0f ( $obs1 ) " & " %9.0f ( $obs2 ) " & " %9.0f ( $obs3 )  " \\ " _n
$WRITE  "Optimal bandwidth ($\pm$ days) & "  %9.0f ( $bw1 ) " & " %9.0f ( $bw2 )  " & " %9.0f ( $bw3 )   " \\" _n
$WRITE "    \hline \hline" _n
$WRITE "\multicolumn{4}{p{0.8\textwidth}}{\scriptsize Regression coefficients from local linear regression shown with robust standard errors (clustered by mother) in parentheses. The estimation samples are determined by an adaptive mean-squared error optimal bandwidth selection. All models include the distance variable and its interaction with the DACA eligibility indicator. ER-Emergency room. ER visits include visits to urgent care. See text for details.}" _n
$WRITE "    \end{tabular} " _n
$WRITE " \end{table} " _n
file close myfile



/// Fig. S.13: Effect of Mothers’ DACA Eligibility on Children’s Mental Health ((Children with at least one Health Care Visit in Post-DACA Period))
global yvars = "y_300308309 y_308309 y_300"
capture matrix drop res
cap local drop counter
local counter = 1
foreach y of global yvars {
rdbwselect `y' rvd  if mother_CWCX==1 & y_visit>0, vce(cluster clid)
global bw`counter' = `e(h_mserd)'
reg `y' Z##c.rvd   if mother_CWCX==1 & bwd<=`e(h_mserd)' & female==0, cl(mother_SAK_RECIP)
global pe1`counter' = _b[1.Z]
global se1`counter' = _se[1.Z]
global ppe`counter' =  (_b[1.Z] / _b[_cons])*100
global pe2`counter' = _b[_cons]
global se2`counter' = _se[_cons]
global obs`counter' = `e(N)'
local counter = `counter' + 1
di "`counter'"
matrix coefse = _b[1.Z] , _se[1.Z]
matrix rownames coefse = "`y'"
matlist coefse
mat res = nullmat(res) \ coefse
}
cd  "$path/daca_oregon_notshared/results/"
matlist res
mat2txt , matrix(res) saving(res_figS13.txt) replace

/// Table S.17: Regression Discontinuity Design Estimates: Effect of Mothers’ DACA Eligibility on Children’s Mental Health (Children with at least one Health Care Visit Post-DACA Period)
cd "/Users/jhainmueller/Dropbox (IPL)/daca_oregon/draft/Science/tables"
cap file close myfile
file open myfile using tabS17.tex, write replace
global WRITE file write myfile
$WRITE "\begin{table}[!hbt]" _n
$WRITE "  \centering" _n
$WRITE "  \small" _n
$WRITE "  \caption{\bf Regression Discontinuity Design Estimates: Effect of Mothers' DACA Eligibility on Children's Mental Health (Children With at Least One Health Care Visit Post-DACA Period)}\label{tab:S17}" _n
$WRITE "    \begin{tabular}{lccc}" _n
$WRITE "    \hline \hline" _n
$WRITE "          &    Adjustment or  & Adjustment  & Anxiety    \\" _n
$WRITE " Outcome         &    Anxiety Disorder      & Disorder & Disorder    \\" _n
$WRITE "\hline" _n
$WRITE "  Model        &    (1)   & (2)  & (3)    \\" _n
$WRITE "\hline" _n
$WRITE  "Effect of Mothers'   & "  %9.2f ( $pe11 ) " & " %9.2f ( $pe12 ) " & "  %9.2f ( $pe13 )  " \\" _n
$WRITE  "DACA Eligibility  & ("  %9.2f ( $se11 ) ") & (" %9.2f ( $se12 ) ") & ("  %9.2f ( $se13 )  ") \\" _n
$WRITE "\hline" _n
$WRITE  "Number of children & "  %9.0f ( $obs1 ) " & " %9.0f ( $obs2 ) " & " %9.0f ($obs3) " \\ " _n
$WRITE  "Optimal bandwidth ($\pm$ days) & "  %9.0f ( $bw1 ) " & " %9.0f ( $bw2 ) " & "  %9.0f ( $bw3 )  " \\" _n
$WRITE "\hline" _n
$WRITE  "Percent change ($100\,(\frac{\hat{\tau}}{\hat{\alpha}}$)) & "  %9.2f ( $ppe1 ) " & " %9.2f ( $ppe2 ) " & "  %9.2f ( $ppe3 )  " \\" _n
$WRITE "    \hline \hline" _n
$WRITE "\multicolumn{4}{p{0.8\textwidth}}{\scriptsize Regression coefficients from local linear regression shown with robust standard errors (clustered by mother) in parentheses. The estimation samples are determined by an adaptive mean-squared error optimal bandwidth selection. All models include the distance variable and its interaction with the DACA eligibility indicator. The outcome variables are coded as 0 or 100 such that the effect estimates of the regression coefficients are measured in percentage points. The percent change in the last row is computed as $100\,(\frac{\hat{\tau}}{\hat{\alpha}}$) and measures at the DACA birthdate cutoff the effect of mothers' DACA elegibility ($\hat{\tau}$) divided by the estimated average diagnoses rate for children of ineligible mothers ($\hat{\alpha}$). See text for details.}" _n
$WRITE "    \end{tabular} " _n
$WRITE " \end{table} " _n
file close myfile










